package com.feihong.dubbo.publish.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.feihong.dubbo.api.service.StudentService;
import com.feihong.dubbo.model.dto.student.StudentDTO;
import com.feihong.dubbo.model.entity.Student;
import com.feihong.dubbo.model.util.transform.ObjectTransformUtil;
import com.feihong.dubbo.repo.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author zhufeihong
 * @since 2019/7/5-2:12
 */
@Slf4j
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public StudentDTO findByNumber(String number) {
        if (number == null) {
            return null;
        }
        Student student = studentMapper.selectOne(new QueryWrapper<Student>().eq("student_number" , number));
        if (student == null) {
            return null;
        }
        return ObjectTransformUtil.copyProperties(student, StudentDTO.class);
    }
}
